package cn.sc.summer.constant.service;

import cn.hutool.core.text.CharSequenceUtil;

import java.io.Serializable;

/**
 * API information is supported to determine the types of data sources supported by this class
 *
 * @author a-xin
 * @date 2024/8/28 13:24
 */
public interface Support extends Serializable {

    /**
     * Supported by default
     */
    String DEFAULT = "DEFAULT";

    /**
     * Determine the types of data sources supported by this class
     *
     * @return Supported types
     */
    String supports();

    /**
     * Obtain information about the currently supported data sources
     *
     * @return Supported types
     */
    default String getSupports() {
        if (CharSequenceUtil.isBlank(this.supports())) {
            return "";
        }
        return this.supports().toLowerCase();
    }

    /**
     * Verify that the data is valid and supported
     *
     * @param check Verification values
     * @return Yes or no
     */
    default Boolean checkSupports(String check) {
        if (CharSequenceUtil.isBlank(check) || CharSequenceUtil.isBlank(getSupports())) {
            return Boolean.FALSE;
        }
        if (check.equalsIgnoreCase(getSupports())) {
            return Boolean.TRUE;
        }
        return Boolean.FALSE;
    }

}
